package com.qdaily.ui.ui;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;

import com.qdaily.ui.QDBaseActivity;
import com.qdaily.ui.R;

import java.io.File;

import uk.co.senab.photoview.PhotoView;

/**
 * Created by song on 15/5/19.
 */
public class ImageShowActivity extends QDBaseActivity{
    private PhotoView imageshow_img;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_image_show);

        imageshow_img = (PhotoView) this.findViewById(R.id.imageshow_img);

        File imgpath = (File)getIntent().getSerializableExtra("ImgPath");
        Bitmap bm = getIntent().getParcelableExtra("Bitmap");
        if (bm == null && imgpath != null)
        {
            bm = BitmapFactory.decodeFile(imgpath.getAbsolutePath());
        }
        if (bm != null)
        {
            imageshow_img.setImageBitmap(bm);
        }
    }

    @Override
    protected void onDestroy() {
        imageshow_img.setImageBitmap(null);
        super.onDestroy();
    }

    public void onDelete(View view)
    {
        Intent intent = getIntent();
        intent.putExtra("isDelete", true);
        setResult(RESULT_OK, intent);
        finish();
    }

    public void onSure(View view)
    {
        finish();
    }
}
